<?php
!defined('P_W') && exit('Forbidden');
define('M_P', R_P . "mode/house/");
/**
 * SERVICE
 * 
 * @package weibo_Sale
 * @author  suqian
 */
class weibo_Sale extends baseWeibo {
	var $_hid;
	var $_url;
	function weibo_Sale() {
		$this->_url = $GLOBALS['db_bbsurl']."/index.php?m=house";
	}
	function init($id) {
		$this->_hid = $id;
		require_once(R_P. 'mode/house/require/core.php');
		$saleService = House::LoadService('SecondSaleService');
		$housefieldsService = House::loadService('HouseFieldsService');
		$saleModule = $saleService->getHouseSaleModule($id);
		empty($saleModule) && Showmsg('data_error');
		$common = sprintf("[url=%s] %s [/url]", $this->_url . "&q=sale&a=houseinfo&houseid=".$this->_hid,$saleModule->subject);
		$title = $common;
		$content = " \n".$common;;
		$position = '';
		if($saleModule->areatype){
			$areaField = $housefieldsService->getCompsiteFieldsByType('area');//
			$areaCode = $saleModule->areatype;
			$areaName = $areaField[$areaCode];
			$area = sprintf("[url=%s] %s [/url]", $this->_url . "&q=sale&options=opt.areatype.".$areaCode,$areaName);  
			$postion .= $area;
		}
		
		if($saleModule->plate){
			$plateField = $housefieldsService->getCompsiteFieldsByType('plate');//
			$plateValue = $saleModule->plate;
			$plateName = $plateField[$plateValue];
			$plate = sprintf("[url=%s] %s [/url]", $this->_url . "&q=sale&options=opt.plate.".$plateValue, $plateName);    
			$postion .= $plate;
		}
		$postion .= $saleModule->address;
		
		$mailSubject =  "";
		$mailContent = "$title &nbsp;\n: $postion \n'";
		$this->_content = $content;
		$this->_mailSubject = $mailSubject;
		$this->_mailContent = $mailContent;
	}
}
?>